#include <iostream>
#include <algorithm>

using namespace std;

long long dp[1024][40086] = {};
int ipt[1024];

int main(int argc, char const *argv[])
{
    long long rst = 0;
    int n, t;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> ipt[i];
        rst++;
        for (int j = 0; j < i; j++)
        {            
            dp[i][ipt[i] - ipt[j] + 20000] 
                += dp[j][ipt[i] - ipt[j] + 20000] + 1;
            dp[i][ipt[i] - ipt[j] + 20000] %= 998244353;
            rst += dp[j][ipt[i] - ipt[j] + 20000] + 1;
            rst %= 998244353;
            
            // cout << ipt[i] << " " << ipt[j] << " " 
            //     << ipt[i] - ipt[j] << " " 
            //     << dp[i][ipt[i] - ipt[j] + 10000] << " "
            //     << rst << " "
            //     << endl;  
        }
    }
    cout << (rst) % 998244353;
    
    return 0;
}
